/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Labsystem;

import HibernateUtil.HibernateUtil;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;
/**
 *
 * @author horacio
 */
public class DaoImpl {
    
    Session session = HibernateUtil.getSession();
    
    public void agregar(Object Obj){
        session.beginTransaction();
        session.save(Obj);
        session.getTransaction().commit();
    }
    
    public void eliminar(Object Obj){
        session.beginTransaction();
        session.delete(Obj);
        session.getTransaction().commit();
    }
    
    public void modificar(Object Obj){
        session.beginTransaction();
        session.update(Obj);
        session.getTransaction().commit();
    }
    
    public List<Object> ejecutarQuery(String query){
        session.beginTransaction();
        Query q = session.createQuery(query);
        List lista = q.list();
        return lista;
        
        //session.getSessionFactory().close();
    }
    
}
